import 'package:flustars/flustars.dart';
import 'package:flutter/cupertino.dart';

///转为 rpx
double toRpx(BuildContext context, double size) {
  double rpx = MediaQuery.of(context).size.width / 750;
  return size * rpx;
}

///数字简化为k/w格式   123456 => 12.3w
formatCharCount(int count) {
  if (count <= 0 || count.isNaN) {
    return '0';
  } else if (count < 10000) {
    return count.toString();
  } else if (count < 10000000) {
    return ((NumUtil.getNumByValueDouble(count / 10000, 1))
                ?.toStringAsFixed(1)
                .toString() ??
            '') +
        '万';
  } else {
    return ((NumUtil.getNumByValueDouble(count / 10000000, 1))
                ?.toStringAsFixed(1)
                .toString() ??
            '') +
        '千万';
  }
}
